package nc.nc_xiuxian;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;

import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import static nc.nc_xiuxian.JQHFTACK.JQHF;

public final class NC_XIUXIAN extends JavaPlugin {
    static NC_XIUXIAN plugin;
    List<String>playerlist=new ArrayList<>();//全服玩家列表
    HashMap<String,String>playerjj=new HashMap<>();//全服玩家境界
    HashMap<String,HashMap<String,Double>>playersx=new HashMap<>();//玩家属性
    HashMap<String,BukkitTask>hfsask=new HashMap<>();

    @Override
    public void onEnable() {
        plugin = this;
        saveDefaultConfig();
        try {
            JINGJIE.playerlistload();
            Bukkit.getPluginManager().registerEvents(new LISTENER_FILELOAD(),this);
            Bukkit.getPluginCommand("xiuxian").setExecutor(new COMMAND());
            JQHF();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        new BukkitRunnable() {
            @Override
            public void run() {
                for(Player player:Bukkit.getOnlinePlayers()){
                    SHUXING.playerallsxupdata(player);
                }
            }
        }.runTaskTimer(plugin,0L,20L);
        // Plugin startup logic

    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }
    public static double ywxs(double d){
        DecimalFormat decimalFormat = new DecimalFormat("#.0"); // 定义格式，保留一位小数
        String formattedNumber = decimalFormat.format(d);
        return Double.parseDouble(formattedNumber);
    }
}
